<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增邀请码管理')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-yqm-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">代理ID：</label>
            <div class="col-sm-8">
                <input name="userId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">邀请码：</label>
            <div class="col-sm-8">
                <input name="yqm" onclick="show();" id="code" class="form-control" type="text">
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "system/yqm";
    $("#form-yqm-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-yqm-add').serialize());
        }
    }

    function codes(n) {
        const a = "azxcvbnmsdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP0123456789";
        let b = "";
        for (let i = 0; i < n; i++) {
            const index = Math.floor(Math.random() * 62);
            b += a.charAt(index);
        }
        return b;

    }

    function show() {
        document.getElementById("code").value = codes(8);
    }

    window.onload = show;


</script>
</body>
</html>